# Samba ***Copyright © Quectel Wireless Solutions Co., Ltd. 2026. All rights reserved.*** --- Samba is a common tool for building file sharing and access control services on Linux systems. It uses the SMB protocol to enable file sharing between different devices within a local area network. By deploying Samba locally, you can conveniently provide shared directories to Windows, Linux, or macOS clients, facilitating cross-platform file transfer and collaboration. This document introduces how to configure the Samba file sharing service on a Debian/Linux system, allowing Windows computers to directly access the device’s shared folders. # Preparation 1. Confirm the device environment. - The device is now able to connect the network normally. - The Windows host and the device are in the same local area network. 2. Check network connectivity. - Execute ping 8.8.8.8 in the terminal. If you can see response time information, it indicates that the network is normal. # Install Samba service Samba is a service program used for sharing files with Windows systems on Debian/Linux. 1. Update the package list: ```plaintext sudo apt-get update ``` 1. This operation ensures the system obtains the latest software source information to avoid the installation of outdated software. 2. Install Samba and client tools: ```plaintext sudo apt-get install samba sudo apt-get install smbclient ``` > 1. **samba**:Server-side software used to provide sharing services. > 2. **smbclient**:Client tool used to test whether the connection is successful. 3. Confirm Samba installation is successful: ```plaintext sudo samba -V ``` # Create a shared folder 1. Create the shared directory: ```plaintext mkdir -p /home/pi/share ``` 1. Create a test file: ```plaintext touch /home/pi/share/test.txt ``` 1. Modify permissions: ```plaintext chmod -R 777 /home/pi/share ``` # Configure Samba service 1. Open the configuration file: ```plaintext sudo vim /etc/samba/smb.conf ``` 1. If you are not familiar with vim, you can use other editors such as nano. ```plaintext sudo nano /etc/samba/smb.conf ``` 1. Scroll to the end of the file and add the following content: ```plaintext [myshare] comment = My Shared Folder browseable = yes path = /home/pi/share create mask = 0777 directory mask = 0777 valid users = pi force user = pi force group = pi public = yes writable = yes available = yes ``` > 1. **[myshare]**----The name of the shared folder as seen by Windows clients when accessing. > 2. **path**----The actual path of the shared directory. > 3. **create mask / directory mask**----The default permissions for newly created files/folders. > 4. **vaild users** ----Legitimate users allowed to access the Samba server. The example user here is pi. > 5. **writable = yes**----Allows clients to create, modify, and delete files in this directory. # Set Samba user and password Samba login users require a separately set password. Taking the system user pi as an example: ```plaintext sudo smbpasswd -a pi ``` Enter the password twice for confirmation (this password will be required when accessing from Windows). # Restart Samba service for configuration to take effect ```plaintext sudo systemctl restart smbd ``` Set Samba to start automatically on boot: ```plaintext sudo systemctl enable smbd ``` # Add firewall rules ```plaintext #Add allowed ports sudo iptables -A INPUT -p tcp -m tcp --dport 445 -j ACCEPT sudo iptables -A INPUT -p tcp -m tcp --dport 139 -j ACCEPT #Allow client IPs through the firewall sudo iptables -A INPUT -p icmp --icmp-type echo-request -s 192.xx.xx.xx -j ACCEPT #Saving Rules sudo sh -c 'iptables-save > /etc/iptables/rules.v4' ``` # Check device IP address ```plaintext sudo ifconfig ``` # Access shared folder from a Windows computer 1. Press "**Win+R**" to open the Run dialog. 2. Enter " **\\ + device IP address** ". ```{image} images/image_TiW2bFI51omBtRxPLRUcNJoKnSe.webp :width: 393px :height: 202px ``` 3. Enter the username and password to access the contents of the shared folder. > 1. Username: pi > 2. Password: The password set using **sudo smbpasswd -a pi** ```{image} images/image_JewWbYMiToXIwOx4KiZcuxCLnac.webp :width: 459px :height: 451px ``` After successful access, you can see the previously created test file *test.txt*.